package amani.wechat.platform.services.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import amani.wechat.platform.services.ICommonService;
import amani.wechat.platform.services.IStorefrontService;
import amani.wechat.platform.webserviceClient.CommonServicePortType;
import amani.wechat.platform.webserviceClient.Designer;
import amani.wechat.platform.webserviceClient.Project;
import amani.wechat.platform.webserviceClient.Works;

@Service("StorefrontService")
public class StorefrontService implements IStorefrontService {
	private static CommonServicePortType commonserviceProxy;
	
	@Resource(name="CommonService")
	ICommonService commonService ;

	static {
		amani.wechat.platform.webserviceClient.CommonService cs = new amani.wechat.platform.webserviceClient.CommonService();
		commonserviceProxy = cs.getCommonServiceHttpPort();
	}

	@Override
	public List<Works> pageWorks(int page,double xcoordinate,double ycoordinate) {
		List<Works> worksList = commonserviceProxy.pageWorks(page*4, (page+1)*4, xcoordinate, ycoordinate).getWorks();
		//List<Works> worksList = new ArrayList<Works>();
		return worksList;
	}
	
	@Override
	public List<Works> pageWorks(int page,String designer) {
		List<Works> worksList = commonserviceProxy.pageWorksByDesigner(page*4, (page+1)*4,designer).getWorks();
		//List<Works> worksList = new ArrayList<Works>();
		return worksList;
	}

	@Override
	public Works getWorks(int id) {
		Works works = commonserviceProxy.loadWorks(id);
		//Works works = null;
		//		Works works = new Works(1,"/AmaniWechatPlatform/content/images/head.jpg","/AmaniWechatPlatform/content/images/p1_zuopin.png","Tony","首席",500,10,89,
//				"描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述","脸型1、脸型2、脸型3"); 
		return works;
	}

	@Override
	public List<Project> listProjects(String type) {
		List<Project> projects = null;
		if("all".equals(type)){
			projects = commonserviceProxy.loadAllProject().getProject();
		}else{
			projects = commonserviceProxy.loadProjectByType(type).getProject();
		}
		
//		List<Project> projects = new ArrayList<Project>();
//		for(int i = 0;i<4;i++){
//			Project tmp = new Project("1","XXXXX面部护理","http://v2.bootcss.com/assets/img/bootstrap-mdo-sfmoma-02.jpg","45","功效功效、功效功效、功效功效","192","220");
//			projects.add(tmp);
//		}
		return projects;
	}

	@Override
	public Designer getDesigner(String id) {
		Designer aDesigner = commonserviceProxy.loadDesigner(id);
//		Designer aDesigner = new Designer("1","/AmaniWechatPlatform/content/images/head.jpg","Tony","首席",5,5,516,"个人定制、造型","个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介","四平路2000号-五角场店");
		return aDesigner;
	}

	@Override
	public Map<String, Object> getWchatProduct(String productId) {
		return commonService.loadWchatProduct(productId);
	}

	@Override
	public List<Map<String, Object>> getProductDetail(String productId) {
		return commonService.loadProductDetail(productId);
	}

	@Override
	public List<Map<String, Object>> getProductPackage(String productId) {
		return commonService.loadProductPackage(productId);
	}

//	@Override
//	public List<Works> pageWorks(int page) {
////		List<Works> worksList = new ArrayList<Works>();
////		for(int i = 0;i<4;i++){
////			Works works = new Works(1,"/AmaniWechatPlatform/content/images/head.jpg","/AmaniWechatPlatform/content/images/p1_zuopin.png","Tony","首席",500,10,89); 
////			worksList.add(works);
////		}
//		return worksList;
//	}
//	
//	@Override
//	public List<Works> pageWorks(int page,int designer) {
////		List<Works> worksList = new ArrayList<Works>();
////		for(int i = 0;i<4;i++){
////			Works works = new Works(1,"/AmaniWechatPlatform/content/images/head.jpg","/AmaniWechatPlatform/content/images/p1_zuopin.png","Tony","首席",500,10,89); 
////			worksList.add(works);
////		}
//		return worksList;
//	}
//
//	@Override
//	public Works getWorks(int id) {
////		Works works = new Works(1,"/AmaniWechatPlatform/content/images/head.jpg","/AmaniWechatPlatform/content/images/p1_zuopin.png","Tony","首席",500,10,89,
////				"描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述","脸型1、脸型2、脸型3"); 
//		return works;
//	}
//
//	@Override
//	public List<Project> listProjects(String type) {
////		List<Project> projects = new ArrayList<Project>();
////		for(int i = 0;i<4;i++){
////			Project tmp = new Project(1,"XXXXX面部护理","http://v2.bootcss.com/assets/img/bootstrap-mdo-sfmoma-02.jpg","45","功效功效、功效功效、功效功效","192","220");
////			projects.add(tmp);
////		}
//		return projects;
//	}
//
//	@Override
//	public Designer getDesigner(int id) {
//		Designer aDesigner = new Designer(1,"/AmaniWechatPlatform/content/images/head.jpg","Tony","首席",5,5,516,"个人定制、造型","个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介个人简介","四平路2000号-五角场店");
//		return aDesigner;
//	}
	
	
}
